Repository navigation
Restore Python static checks on main - #9082
loopx-agent wants to merge 2 commits into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
主干开发者运行配置中的 Python kernel mypy 和测试集 Ruff。实际 quota 调用也会在无结算计划时显示下一条可执行命令。主干的调用者允许缺省计划,helper 类型却只接受 Mapping。候选把类型与已有分支对齐,并移除监控测试的无用导入。相同本地命令在主干复现两个静态错误,候选通过。无计划、同 Todo 计划与其他 Todo 计划的命令逐字相同。变更仅涉及静态验收与已有命令的类型声明。平台测试、合入许可和运行时采用沿各自现有流程。
改动思路 / Approach
已有 CLI 主流程允许结算计划缺省。候选只调整 successor replan helper 的参数类型,并删除 Steward 测试里未引用的导入。两次提交分别改一个参数注解和一个测试导入。结算计划、配额、工作区准入与监控运行时仍复用原模块。保留实际处理缺省计划的既有实现,静态类型直接表达调用允许的输入。测试文件保持原测试函数及断言。
具体改动 / Changes
精确 head be17fad48c4d3cae4043fe158ecf75f75f49862c,diff base 6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25,2 个文件 +1/-2。逐项复核 kernel-optional-plan、steward-lint-import。验收约定
关键代码讲解
- 将 settlement_plan 注解改为 Mapping[str, object] | None。上游调用原本就允许传入 None,十七个 kernel 文件通过 mypy。源码
- 同一 Todo 的计划保留原绑定命令,缺省或其他 Todo 计划仍返回原有 replan、refresh 和 spend 指引。源码
- 删除未引用的 pytest 导入,保留同一监控测试代码和断言。源码
对主干的风险 / Risks
可观察风险在缺省计划落到错误的同轮 guard,或 lint 修改误删测试依赖。两版本去掉该注解和确实未被引用的导入后,Python AST 完全一致。三个计划输入的渲染命令也逐字一致。
语义与 CI 对齐
相同 mypy 版本检查 17 个 kernel 文件,主干报可选参数错误,候选通过。配置的 Ruff 在主干报 F401,候选通过。两版本各通过十项结算 CLI 检查。初跑监控等待项在两版本超时,串行复跑候选七项全过,基线仍有同一等待超时。等待原因未归定。测试逻辑及运行时实现保持一致,未使用托管 CI 状态。
我的整体评价 / Verdict
批准当前提交。精确基线的两个静态失败在候选修复,缺省计划投影和监控测试行为得到对照。保留监控等待的本地波动和平台覆盖边界,合入资格按既有独立流程判断。
English verdict: APPROVE. The exact head restores both configured Python gates while the native CLI and optional-plan command controls preserve behavior.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google (self_reported)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
主干贡献者、本地预检查执行者以及受管工作项恢复路径的维护者会触发或受影响于此问题。在基线 6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25 上运行官方配置的 mypy 与 CI ruff check 时,工作项重规划动作辅助函数的参数注解遗漏了 | None,且 Steward 监控测试保留了一个未使用的 pytest 导入,导致主干及基于主干的其他 PR 的静态门禁持续报红。修复前在同一基线执行官方配置 mypy 与 CI Ruff 命令,会立即因参数可空性注解不一致和 F401 未使用导入而退出失败;修复后相同检查全部通过,而无论 settlement_plan 为 None、同 Todo 计划还是其他 Todo 计划,运行时生成的命令行动作序列保持逐字一致。核心 17 个文件 mypy、Todo CLI 适配器 mypy 与 CI Ruff 静态检查均从基线失败转为全部通过,相关工作项重试与 Steward 通用监控测试全部通过且运行时行为无漂移。本 PR 不修改任何运行时交互逻辑、控制面策略、协议字段或跨平台矩阵覆盖范围。不处理则会持续污染主干门禁;该变更是一份独立完整、可随时回退的静态修复切片。
改动思路 / Approach
整个改动围绕“最小对齐、零运行时漂移”展开:在工作项交互契约投影链路中,interaction_next_cli_actions 经由 _admitted_interaction_next_cli_actions 调用 _successor_replan_required_cli_actions 时,上游签名与 _turn_scoped_cli_settlement_context 本就允许 settlement_plan 为 None,而下游 _deferred_resume_continuation 与 settlement_binding_args 也已显式接受 Mapping | None 并安全回退到标准重规划命令。因此候选没有增加冗余非空断言或新包装层,而是直接把 _successor_replan_required_cli_actions 的 settlement_plan 参数类型对齐为 Mapping[str, object] | None,并同步删除 test_steward_generic_monitor_todo.py 中多余的 import pytest。本次修改直接在原有投影函数签名上如实声明已有运行时可空输入并清理测试死导入,不新增状态、包装层或并行控制路径,与下游安全解引用契约完全一致。仅限于修复主干两个确定性 Python 静态检查失败,不顺带修改运行时交互逻辑、最新主干同步或其他测试套件。
具体改动 / Changes
本次评审精确目标提交为 be17fad48c4d3cae4043fe158ecf75f75f49862c,依据 .github/workflows/python-tests.yml(基线提交 6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25)定义的 Python 静态门禁逐项核对,2 个文件共 +1/-2:
kernel-contracts-mypy->implemented:修复interaction_contract.py可空参数类型不匹配,17 个核心文件 mypy 与 2 个 Todo CLI 适配器 mypy 全部通过。kernel-static-checks-ruff->implemented:移除test_steward_generic_monitor_todo.py未使用的pytest导入,CI Ruff 全套检查全部通过。
关键代码讲解
_successor_replan_required_cli_actions:将第 765 行settlement_plan参数类型从Mapping[str, object]改为Mapping[str, object] | None。函数内部唯一读取settlement_plan的第 818 行仅把它透传给_deferred_resume_continuation,因此修正签名后即可与运行时控制流完全一致,且不改动任何可执行 AST。_admitted_interaction_next_cli_actions:全仓唯一调用方。其第 839 行参数本身即为Mapping[str, Any] | None = None,当_turn_scoped_cli_settlement_context未绑定特定结算计划时合法传递None,此前在第 1004 行触发 mypyarg-type报错。_deferred_resume_continuation:负责判定settlement_plan中的identity.todo_id是否与当前恢复的todo_id匹配;若为None或不匹配则安全返回None,使上层回退到todo update --status open --clear-resume-when、refresh-state与quota spend-slot。test_generic_signal_monitor_triggers_handoff_and_deduped_user_actions:通读整文件第 1–327 行确认完全未使用pytest模块对象(未调用pytest.raises、pytest.mark等),删除第 7 行冗余导入后所有测试逻辑与断言保持原样。
对主干的风险 / Risks
核心潜在风险在于:类型放宽后 settlement_plan=None 是否会在下游触发空指针异常,或删除 pytest 导入是否破坏隐藏的测试夹具依赖,以及 PR 基线略落后于当前 origin/main(b927e20bfbe60817570bceb8654e2bfbc96abadf)是否引入额外冲突。
经逐一核查与实测验证:
- 下游空值与动作对照:在
6a0f8bc17b与be17fad48c两个提交上以相同输入对比调用interaction_next_cli_actions(mode="successor_replan_required"),分别传入settlement_plan=None与绑定todo_id的有效计划,两版输出的 3 条 CLI 动作列表完全逐字一致。 - 主干漂移核查:检查
6a0f8bc17b..origin/main区间日志与文件变更,确认后续合入主干的提交均未修改interaction_contract.py或test_steward_generic_monitor_todo.py,且当前origin/main自身仍复现完全相同的两个 mypy 与 Ruff 错误;此外 PR #9084 已 cherry-pick 这两个提交并顺利通过联合静态检查。 - 本地验证矩阵(隔离 worktree 实测,未依赖/等待远端 CI):
- 基线
6a0f8bc17b对比:python -m mypy复现第 1004 行arg-type错误;CI Ruff 复现第 7 行F401错误。 - 候选
be17fad48c静态检查:python -m mypy(17 个核心文件)PASS;python -m mypy --strict --follow-imports=silent loopx/control_plane/work_items/interaction_contract.pyPASS;Todo 适配器mypy(2 个文件)PASS;CI Ruff 全套检查 PASS。 - 候选行为与回归测试:
pytest -n 4执行test_stage2c_dependency_lock.py、test_top_level_module_budget.py、test_quota_settlement_cli.py、test_steward_generic_monitor_todo.py共 224 项全部 PASS;test_replan_writeback_projection.py与test_stride_observation.py共 70 项全部 PASS;loopx canary premerge(含 4 项直接检查、Python 编译、10 项 catalog canary 含semantic-vocabulary-drift-smoke、8 项 risk-profile smoke)共 18/18 项全部 PASS。
- 基线
我的整体评价 / Verdict
本次修复体量极小但精准击中主干静态门禁阻塞点。就长程收益与用户体验而言(long_horizon=preserved,user_experience=preserved):运行时动作选择、工作项恢复链路与用户侧交付界面均完整保留;因为本次仅涉及 Python 类型注解与测试文件无用导入清理,已检查变更路径不涉及任何渲染界面。未在本机覆盖的边界仅限远端托管跨平台完整矩阵(如 Windows)。在代码体量、架构归属与语义规范方面:不引入或修改任何共享语义词表,属于零复杂度增加的局部修复(local_only / not_applicable),无额外兼容负担。基于精确头 be17fad48c4d3cae4043fe158ecf75f75f49862c 上完整的静态复现/修复证据与全部 294 项测试 + 18 项 premerge canary 实测通过,给出批准结论(当前 PR 状态保持 OPEN,不执行合入操作)。
English verdict: APPROVE at exact head be17fad. Both configured main Python static failures (mypy optional settlement_plan mismatch in interaction_contract.py and Ruff F401 unused pytest import in test_steward_generic_monitor_todo.py) reproduce on the base and pass cleanly on the candidate head with verified behavioral parity and passing local pytest and premerge canary checks.
Goal And Delivered Outcome
Two Python static checks fail on the tested
mainrevision. The successor replan helper now accepts a missing settlement plan in its annotation, matching the existing deferred-resume fallback. The Steward generic monitor test drops an unusedpytestimport. The configured mypy and CI Ruff commands both pass on the proposed head. Successor replan extraction · Steward monitor changesAuthor Declaration
Written by
model_agent(OpenAI Codex, GPT-6).Implemented against
The request in this PR and the Python checks defined in
.github/workflows/python-tests.ymlat the tested base are the basis.loopx/control_plane/work_items/interaction_contract.pytests/test_steward_generic_monitor_todo.pyValidation
Tested revision
be17fad48c4d3cae4043fe158ecf75f75f49862cagainst6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25onmain. Local runs finished. The behavioral tests use synthetic fixtures.staticpassedpython -m mypypassed across all 17 configured kernel files. The separate Todo adapter mypy command passed for both paths.staticpassedpython -m ruff check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentationpassed.regression_paritypassedreal_entrypointpassedunitpassedstaticpassedintegrationnot_runIndependent review of this head is pending.
Frontend / Visual Evidence
UI impact is
none.Type of Change
LoopX Area
Both commits carry DCO sign-off. Validation disclosure guidance